home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2001 May / SGI IRIX Base Documentation 2001 May.iso / usr / share / catman / p_man / cat3 / ckpt_create.z / ckpt_create
Encoding:
Text File  |  2001-04-17  |  17.7 KB  |  463 lines

  1.  
  2.  
  3.  
  4. cccckkkkpppptttt____ccccrrrreeeeaaaatttteeee((((3333))))                                                  cccckkkkpppptttt____ccccrrrreeeeaaaatttteeee((((3333))))
  5.  
  6.  
  7.  
  8. NNNNAAAAMMMMEEEE
  9.      ckpt_setup, ckpt_create, ckpt_restart, ckpt_stat, ckpt_remove -
  10.      checkpoint and restart (CPR) library interfaces
  11.  
  12. SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  13.      #include <ckpt.h>
  14.  
  15.      int ckpt_setup(struct ckpt_args *_a_r_g_s[], size_t _n_a_r_g_s);
  16.  
  17.      int ckpt_create(const char *_p_a_t_h, ckpt_id_t _i_d, u_long _t_y_p_e,
  18.           struct ckpt_args *_a_r_g_s[], size_t _n_a_r_g_s);
  19.  
  20.      ckpt_id_t ckpt_restart(const char *_p_a_t_h, struct ckpt_args *_a_r_g_s[],
  21.           size_t _n_a_r_g_s);
  22.  
  23.      int ckpt_stat(const char *_p_a_t_h, struct ckpt_stat **_s_p);
  24.  
  25.      int ckpt_remove(const char *_p_a_t_h);
  26.  
  27. DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  28.      The functions provided here are used to issue checkpoint and restart
  29.      (CPR) requests to a process or group of processes.  The _c_k_p_t__s_e_t_u_p,
  30.      _c_k_p_t__c_r_e_a_t_e, _c_k_p_t__r_e_s_t_a_r_t, and _c_k_p_t__r_e_m_o_v_e routines are implemented
  31.      according to the IEEE standard POSIX 1003.1m Draft 1, with minor
  32.      modifications (described below).  The _c_k_p_t__s_t_a_t function is an IRIX
  33.      extension.  Silicon Graphics intends to follow the future development of
  34.      POSIX 1003.1m draft standards and endeavor to be compliant.
  35.  
  36.    cccckkkkpppptttt____sssseeeettttuuuupppp
  37.      This routine currently does not perform any operation on IRIX systems.
  38.      The interface is reserved for future addition of features.  The POSIX
  39.      _c_k_p_t__a_r_g_s structure defined in <ckpt.h> includes the following members:
  40.  
  41.           unsigned long   ckpt_type;      /* data type */
  42.           void            *ckpt_data;     /* data */
  43.  
  44.      None of the POSIX _c_k_p_t__t_y_p_e definitions (CKPT_ID, CKPT_LOCK, CKPT_SIGNAL,
  45.      CKPT_POSTRESTART, CKPT_PRERESTART, and CKPT_POSTCREATE) is implemented in
  46.      IRIX because CPR handles these functions directly and transparently.
  47.  
  48.    cccckkkkpppptttt____ccccrrrreeeeaaaatttteeee
  49.      This routine performs a checkpoint operation against a process or group
  50.      of processes.  It creates a set of checkpoint statefiles in the directory
  51.      _p_a_t_h, based on the user-specified checkpoint ID _i_d, which has a _t_y_p_e as
  52.      defined in <ckpt.h>:
  53.  
  54.      P_PID   for Unix process ID
  55.      P_PGID  for Unix process group ID
  56.      P_SID   for Unix process session ID; see _t_e_r_m_i_o(7)
  57.      P_ASH   for IRIX Array Session ID; see _a_r_r_a_y__s_e_r_v_i_c_e_s(5)
  58.      P_HID   for process hierarchy (tree) rooted at that PID
  59.      P_SGP   for IRIX sproc shared group; see _s_p_r_o_c(2)
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. cccckkkkpppptttt____ccccrrrreeeeaaaatttteeee((((3333))))                                                  cccckkkkpppptttt____ccccrrrreeeeaaaatttteeee((((3333))))
  71.  
  72.  
  73.  
  74.      P_JID   for IRIX job ID
  75.  
  76.      Note that _c_k_p_t__i_d__t is defined as an _i_n_t_6_4__t type in <ckpt.h>.  The
  77.      original POSIX standard requires _i_d to be a _p_i_d__t which is not long
  78.      enough to support the SGI 64-bit Array ID (ASH) number or the SGI 64-bit
  79.      Job ID (JID) number.  However, any application binary using regular POSIX
  80.      _c_k_p_t__c_r_e_a_t_e should work fine since type casting from 32-bit _p_i_d__t to 64-
  81.      bit _c_k_p_t__i_d__t is transparent.
  82.  
  83.      The *_a_r_g_s[] and _n_a_r_g_s arguments from the POSIX draft standard, similar to
  84.      the definitions in _c_k_p_t__s_e_t_u_p, are ignored in IRIX.
  85.  
  86.      See _c_p_r(1) for more information about the CPR attribute file $_H_O_M_E/._c_p_r,
  87.      checkpointable objects and limitations, the SIGCKPT and SIGRESTART
  88.      signals, event handling using _a_t_c_h_e_c_k_p_o_i_n_t(3C) and _a_t_r_e_s_t_a_r_t(3C), CPR
  89.      security, and other issues.
  90.  
  91.      In addition to the CPR attribute file, a global variable _c_p_r__f_l_a_g_s
  92.      defined in <ckpt.h> may specify checkpoint-related options.  The option
  93.      available is:
  94.  
  95.      CKPT_OPENFILE_DISTRIBUTE
  96.           This flag alters the default location, which is the centralized
  97.           directory given by _p_a_t_h, for saving open files.  Instead, open files
  98.           are saved in the same directory where the original open files
  99.           resided, with a new and unique name identifying them.  For example,
  100.           if a process has the /_e_t_c/_p_a_s_s_w_d file open when a checkpoint is
  101.           issued, with the CKPT_OPENFILE_DISTRIBUTE bit set, the /_e_t_c/_p_a_s_s_w_d
  102.           file is saved distributively in /_e_t_c/_p_a_s_s_w_d._c_k_p_t._p_i_d_X_X_X.  Distribute
  103.           mode is useful when disk space is a concern.  However, the
  104.           centralized mode (the default) is far more secure and self-
  105.           contained.  Users should be cautious when this bit is set.
  106.  
  107.      CKPT_CHECKPOINT_CONT
  108.           This flag makes checkpoint target processes continue running after
  109.           this checkpoint is finished.  It overrides the default WILL policy,
  110.           and the WILL policy specified in a user's CPR attribute file.
  111.  
  112.      CKPT_CHECKPOINT_KILL
  113.           This flag kills checkpoint target processes after this checkpoint is
  114.           finished.  This is the default WILL policy, but overrides a CONT
  115.           setting in the user's CPR attribute file.
  116.  
  117.      CKPT_CHECKPOINT_UPGRADE
  118.           Use this flag only when issuing a checkpoint immediately before an
  119.           operating system upgrade.  This forces a save of all executable
  120.           files and DSO libraries used by the current processes, so that
  121.           target processes can be restarted in an upgraded environment.  This
  122.           flag must be used again if restarted processes must be recursively
  123.           checkpointed in the new environment.
  124.  
  125.  
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. cccckkkkpppptttt____ccccrrrreeeeaaaatttteeee((((3333))))                                                  cccckkkkpppptttt____ccccrrrreeeeaaaatttteeee((((3333))))
  137.  
  138.  
  139.  
  140.    cccckkkkpppptttt____rrrreeeessssttttaaaarrrrtttt
  141.      This routine restarts a set of processes from the statefile created at
  142.      checkpoint time and identified by _p_a_t_h.  If a restart involves more than
  143.      one process, the restart on all processes has to succeed before any
  144.      process is enabled to run.  If one restart in a group fails, all fail.
  145.  
  146.      In addition to the CPR attribute file, a global variable _c_p_r__f_l_a_g_s
  147.      defined in <ckpt.h> may specify checkpoint-related options.  The option
  148.      available is:
  149.  
  150.      CKPT_RESTART_INTERACTIVE
  151.           This flag makes a process or group of processes interactive (that
  152.           is, subject to UNIX job-control), if the original processes were
  153.           interactive.  The calling process or the calling process' group
  154.           leader becomes the group leader of restarted processes, but the
  155.           original process group ID cannot be restored.  Without this flag,
  156.           the default is to restart target processes as an independent process
  157.           group with the original group ID restored.
  158.  
  159.    cccckkkkpppptttt____rrrreeeemmmmoooovvvveeee
  160.      This routine deletes a statefile identified by _p_a_t_h.  The _c_k_p_t__r_e_m_o_v_e
  161.      routine removes all statefiles, including all the saved open files,
  162.      mapped files, pipe data, and so forth.
  163.  
  164.      Only the superuser and the checkpoint owner can remove checkpoint files.
  165.  
  166.    cccckkkkpppptttt____ssssttttaaaatttt
  167.      This routine is issued to existing statefiles in _p_a_t_h to get basic
  168.      information about the checkpointed processes saved there.  The
  169.      information is returned through a single-link list of _c_k_p_t__s_t_a_t__t
  170.      structures pointed by *_s_p, defined in <ckpt.h>.  Each structure
  171.      represents one process with the following members:
  172.  
  173.              struct ckpt_stat  *cs_next;            /* next process */
  174.              long              cs_revision;         /* CPR revision # */
  175.              pid_t             cs_pid;              /* proc pid */
  176.              pid_t             cs_ppid;             /* proc parent pid */
  177.              pid_t             cs_pgrp;             /* proc group leader */
  178.              pid_t             cs_sid;              /* session id */
  179.              struct stat       cs_stat;             /* see stat(2) */
  180.              char              cs_nfiles;           /* # of open files */
  181.              char              cs_comm[PSCOMSIZ];   /* process name */
  182.              char              cs_psargs[PSARGSZ];  /* and arguments */
  183.              char              cs_cdir[MAXPATHLEN]; /* current directory */
  184.              int               cs_board;            /* board (sys/invent.h) */
  185.              int               cs_cpu;              /* cpu (sys/invent.h) */
  186.              int               cs_abi;              /* abi (sys/kabi.h) */
  187.  
  188.      Applications can traverse through the next pointer _c_s__n_e_x_t to reach all
  189.      processes associated with the statefile.
  190.  
  191.  
  192.  
  193.  
  194.  
  195.                                                                         PPPPaaaaggggeeee 3333
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202. cccckkkkpppptttt____ccccrrrreeeeaaaatttteeee((((3333))))                                                  cccckkkkpppptttt____ccccrrrreeeeaaaatttteeee((((3333))))
  203.  
  204.  
  205.  
  206.      It is important to note that although applications are not required to
  207.      allocate the memory buffers needed for the _s_p linked list, it is an
  208.      application's responsibility to release these memory buffers after
  209.      examining the data.  Applications should follow the _c_s__n_e_x_t link to free
  210.      all of the _c_k_p_t__s_t_a_t__t buffers.  The following example shows how to use
  211.      this function:
  212.  
  213.              ckpt_stat_t *sp, *sp_next;
  214.  
  215.              if (ckpt_stat(path, &sp)) < 0)
  216.                  return (-1);
  217.              while (sp) {
  218.                  /* examine the data sp */
  219.                  ...
  220.                  sp_next = sp->cs_next;
  221.                  free(sp);
  222.                  sp = sp_next;
  223.              }
  224.  
  225. NNNNOOOOTTTTEEEESSSS
  226.      All the CPR interfaces are found in the _l_i_b_c_p_r._s_o DSO, and are loaded at
  227.      runtime if the ----llllccccpppprrrr option is passed to _c_c(1) or _l_d(1).
  228.  
  229.      The contents of ckpt_stat_t are likely to change between releases.
  230.  
  231.      The ckpt_stat() interface is not supported for 32 bit abis running on 64
  232.      bit kernels.
  233.  
  234. SSSSEEEEEEEE AAAALLLLSSSSOOOO
  235.      _c_p_r(1), _c_v_i_e_w(1), _a_t_c_h_e_c_k_p_o_i_n_t(3C), _a_t_r_e_s_t_a_r_t(3C)
  236.  
  237.      IEEE standard POSIX 1003.1m Draft 1, October 1995.  This draft standard
  238.      is still being discussed and modified.  No assurances can be given as to
  239.      when P1003.1m will be approved or what it will contain.
  240.  
  241. DDDDIIIIAAAAGGGGNNNNOOOOSSSSTTTTIIIICCCCSSSS
  242.      _c_k_p_t__s_e_t_u_p is a no-op interface and currently always returns 0.
  243.  
  244.      _c_k_p_t__c_r_e_a_t_e returns 0 upon success.  Upon failure it returns -1 and sets
  245.      _e_r_r_n_o to indicate one of the following:
  246.  
  247.      [ECKPT]
  248.           An unrecoverable resource, such as a socket connection, is
  249.           associated with the target process.
  250.  
  251.      [EEXIST]
  252.           The file named by _p_a_t_h already exists.
  253.  
  254.      [ENOMEM]
  255.           Checkpointing requires more memory than allowed by the hardware or
  256.           available swap space.
  257.  
  258.  
  259.  
  260.  
  261.                                                                         PPPPaaaaggggeeee 4444
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268. cccckkkkpppptttt____ccccrrrreeeeaaaatttteeee((((3333))))                                                  cccckkkkpppptttt____ccccrrrreeeeaaaatttteeee((((3333))))
  269.  
  270.  
  271.  
  272.      [ENOSPC]
  273.           Space remaining on the device is insufficient for the checkpoint
  274.           file.
  275.  
  276.      [EACCES]
  277.           Search permission is denied on a component of the path prefix or
  278.           write permission is denied on the parent directory of the checkpoint
  279.           file to be created.
  280.  
  281.      [EPERM]
  282.           The calling process does not have appropriate privileges to
  283.           checkpoint one or more of the target processes.
  284.  
  285.      [EBUSY]
  286.           A resource associated with the target process is in use by the
  287.           system.
  288.  
  289.      [ELOOP]
  290.           Too many symbolic links were encountered during resolution of the
  291.           _p_a_t_h argument; a loop probably exists.
  292.  
  293.      [ENOENT]
  294.           The _p_a_t_h argument names a nonexistent directory or points to an
  295.           empty string.
  296.  
  297.      [ENOTDIR]
  298.           A component of the path prefix is not a directory.
  299.  
  300.      [EROFS]
  301.           The checkpoint file being created would reside on a read-only file
  302.           system.
  303.  
  304.      [EINVAL]
  305.           An invalid argument was passed to the function call.  [ESRCH] The
  306.           process or process group specified by _i_d cannot be found.
  307.  
  308.      _c_k_p_t__r_e_s_t_a_r_t returns the ID (_c_k_p_t__i_d__t) of the restarted process, process
  309.      group leader, session leader, tree root of processes in an array, tree
  310.      root of a process hierarchy, _s_p_r_o_c group leader, or job.  Note that the
  311.      64-bit return value _c_k_p_t__i_d__t is different from the 32-bit value POSIX
  312.      specifies; however, the difference doesn't affect API compatibility.  On
  313.      failure, _c_k_p_t__r_e_s_t_a_r_t returns -1 and sets _e_r_r_n_o to indicate one of the
  314.      following:
  315.  
  316.      [ECKPT]
  317.           Restart operation can not be completed or an unrecoverable resource
  318.           is associated with the target process.
  319.  
  320.      [EBUSY]
  321.           The system resource required to restart the processes requested is
  322.           already taken at this moment.  For example, a process ID is
  323.           currently being used by another process and if the action ORIGINAL
  324.  
  325.  
  326.  
  327.                                                                         PPPPaaaaggggeeee 5555
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334. cccckkkkpppptttt____ccccrrrreeeeaaaatttteeee((((3333))))                                                  cccckkkkpppptttt____ccccrrrreeeeaaaatttteeee((((3333))))
  335.  
  336.  
  337.  
  338.           is set for the FORK function in the $_H_O_M_E/._c_p_r attribute file.
  339.  
  340.      [EAGAIN]
  341.           A system-imposed limit on the total number of processes belonging to
  342.           a single user (CHILD_MAX) would be exceeded by restarting the target
  343.           process set.
  344.  
  345.      [ENOMEM]
  346.           Restarting the target process set requires more memory than allowed
  347.           by the hardware or available swap space.
  348.  
  349.      [EACCES]
  350.           Search permission is denied on a component of the path prefix.
  351.  
  352.      [EPERM]
  353.           The real user ID of the calling process does not match the real user
  354.           ID of one or more processes defined by the checkpoint file, or the
  355.           calling process does not have appropriate privileges to restart one
  356.           or more of the target processes.
  357.  
  358.      [ELOOP]
  359.           Too many symbolic links were encountered during resolution of the
  360.           _p_a_t_h argument; a loop probably exists.
  361.  
  362.      [ENOENT]
  363.           The _p_a_t_h argument names a nonexistent directory or points to an
  364.           empty string.
  365.  
  366.      [ENOTDIR]
  367.           A component of the path prefix is not a directory.
  368.  
  369.      [EROFS]
  370.           Restarted files would be created in a read-only file system.
  371.  
  372.      [EINVAL]
  373.           An invalid argument was passed to the function call.
  374.  
  375.      _c_k_p_t__r_e_m_o_v_e and _c_k_p_t__s_t_a_t return 0 on success.  On failure, they return
  376.      -1 and set _e_r_r_n_o to indicate one of the following:
  377.  
  378.      [EACCES]
  379.           Search permission is denied on a component of the path prefix, or
  380.           write permission is denied on the parent directory of the checkpoint
  381.           file to be removed.
  382.  
  383.      [EPERM]
  384.           The calling process does not have appropriate privileges to remove
  385.           or stat the target statefiles.
  386.  
  387.      [ELOOP]
  388.           Too many symbolic links were encountered during resolution of the
  389.           _p_a_t_h argument; a loop probably exists.
  390.  
  391.  
  392.  
  393.                                                                         PPPPaaaaggggeeee 6666
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400. cccckkkkpppptttt____ccccrrrreeeeaaaatttteeee((((3333))))                                                  cccckkkkpppptttt____ccccrrrreeeeaaaatttteeee((((3333))))
  401.  
  402.  
  403.  
  404.      [ENOENT]
  405.           The _p_a_t_h argument names a nonexistent directory or points to an
  406.           empty string.
  407.  
  408.      [ENOTDIR]
  409.           A component of the path prefix is not a directory.
  410.  
  411.      [EROFS]
  412.           The checkpoint file to be removed resides on a read-only file
  413.           system.
  414.  
  415.      [EINVAL]
  416.           The file to be removed is not a checkpoint file.
  417.  
  418.  
  419.  
  420.  
  421.  
  422.  
  423.  
  424.  
  425.  
  426.  
  427.  
  428.  
  429.  
  430.  
  431.  
  432.  
  433.  
  434.  
  435.  
  436.  
  437.  
  438.  
  439.  
  440.  
  441.  
  442.  
  443.  
  444.  
  445.  
  446.  
  447.  
  448.  
  449.  
  450.  
  451.  
  452.  
  453.  
  454.  
  455.  
  456.  
  457.  
  458.  
  459.                                                                         PPPPaaaaggggeeee 7777
  460.  
  461.  
  462.  
  463.